//
//  MKBaseTabBarController.m
//  singForYou
//
//  Created by nicolas on 2017/3/7.
//  Copyright © 2017年 nicolas. All rights reserved.
//

#import "MKBaseTabBarController.h"

#import "MKMusicNameViewController.h"
#import "MKMapViewController.h"
#import "MKPersonalCenterViewController.h"
#import "MKNewsViewController.h"
#import "MKBaseNavigationController.h"

@interface MKBaseTabBarController ()

@end

@implementation MKBaseTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setupChildVc];
}


- (void)setupChildVc {
    
    MKMusicNameViewController *musicNameVc = [[MKMusicNameViewController alloc] init];
    
    [self addChildVc:musicNameVc andTitle:@"音乐" withImageName:@"tabbar_message_center"];
    MKMapViewController *mapVc =[[MKMapViewController alloc] init];
    [self addChildVc:mapVc andTitle:@"地图" withImageName:@"tabbar_discover"];
    MKNewsViewController *newsVc = [[MKNewsViewController alloc] init];
    [self addChildVc:newsVc andTitle:@"新闻(试题)" withImageName:@"tabbar_home"];
    
    MKPersonalCenterViewController *personalCenterVc = [[MKPersonalCenterViewController alloc] init];
    [self addChildVc:personalCenterVc andTitle:@"个人中心" withImageName:@"tabbar_profile"];
    
}

- (void)addChildVc:(UIViewController *)Vc andTitle:(NSString *)title withImageName:(NSString *)imageName {
    //设置标题
    Vc.title = title;
    //设置tabbar图片
    Vc.tabBarItem.image = [UIImage imageNamed:imageName];
    //设置高亮图片
    Vc.tabBarItem.selectedImage = [[UIImage imageNamed:[NSString stringWithFormat:@"%@_selected",imageName]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    //设置文字选中的颜色
    [Vc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor orangeColor]} forState:UIControlStateSelected];
    //包装导航控制器
    MKBaseNavigationController *naV = [[MKBaseNavigationController alloc] initWithRootViewController:Vc];
    [self addChildViewController:naV];
}

@end
